package com.guoyh.bilbase.pop.pop

import android.content.Context
import com.guoyh.baseutils.mylog.Loger
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.BasePopupView

/**
 * @author Administrator
 */
object LoadingPopUtils {

    private var loadingPop: BasePopupView? = null

    fun showLoad(context: Context?, title: String ? = "请稍后...") {
        Loger.dd("====${context == null}===")
        if (context == null) {
            return
        }
        // 按返回键是否关闭弹窗，默认为true 点击外部是否关闭弹窗，默认为true
        loadingPop = XPopup.Builder(context)
            .dismissOnBackPressed(false) // 按返回键是否关闭弹窗，默认为true
            .dismissOnTouchOutside(false) // 点击外部是否关闭弹窗，默认为true
            .asCustom(LoadingPop(context, title))

        loadingPop!!.show()

    }

    fun hideLoad() {
        Loger.dd("=====hide======")
        if (loadingPop != null) {
            loadingPop!!.dismiss()
        }
    }
}

